package com.xiaodimall.beforesys.controller;

import com.xiaodimall.beforesys.service.GoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author wyc
 * @description
 * @ClassName GoodsController
 * @date 2022/11/26 10:39
 * 商品详情模块
 */
@Controller
public class GoodsController {

    //注入业务层接口
    @Resource
    GoodsService goodsService;

    /**
     * 跳转到商品详情页面
     * @author WYC
     * @param goodsId
     * @param request
     * @return: mall/detail
     * @date: 2022/11/28 10:03
     */
    @ApiOperation(value = "根据id获取商品详情")
    @GetMapping("/goods/detail/{goodsId}")
    public String findByIdGoodsMsg(@PathVariable("goodsId")Long goodsId, HttpServletRequest request) {
        return goodsService.findByIdGoodsMsg(goodsId,request);
    }



    /**
     * 搜索功能
     * @author WYC
     * @param params
     * @param request
     * @return: 返回搜素出来的数据
     * @date: 2022/12/1 20:48
     */
    @ApiOperation(value = "首页搜索功能")
    @GetMapping({"/search", "/search.html"})
    public String searchPage(@RequestParam Map<String, Object> params, HttpServletRequest request) {

        return goodsService.searchGoods(params,request);
    }
}

